package cn.laixueit.controller;

import cn.laixueit.pojo.QueryVo;
import cn.laixueit.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/user")
public class UserController {


    @RequestMapping("/hello")
    public ModelAndView hello(){
        ModelAndView mv = new ModelAndView();
        System.out.println(123);
        mv.setViewName("/index.jsp");
        mv.addObject("msg","hello");
        return mv;
    }

    @GetMapping("/findById")
    public ModelAndView save(String id){
        ModelAndView mv = new ModelAndView();
        System.out.println(id);
        mv.addObject("id",id);
        return mv;
    }

    @PostMapping("/findById2")
    public ModelAndView findById2(String id){
        ModelAndView mv = new ModelAndView();
        System.out.println(id);
        mv.addObject("id",id);
        return mv;
    }

    @PostMapping("/add")
    public ModelAndView add(User user){
        ModelAndView mv = new ModelAndView();
        System.out.println(user);
        return mv;
    }

    @PostMapping("/add2")
    public ModelAndView add2(Integer[] ids){
        ModelAndView mv = new ModelAndView();
        for (int i = 0; i < ids.length; i++) {
            System.out.println("ids = " + ids[i]);
        }
        return mv;
    }

    @PostMapping("/listadd")
    public ModelAndView listadd(QueryVo vo){
        ModelAndView mv = new ModelAndView();
//        vo.getUsers().forEach(System.out::println);
        System.out.println("vo.getMaps().get(\"a\") = " + vo.getMaps().get("a"));
        return mv;
    }



}
